﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Aspose.Cells;

namespace BySoft.Web.Site.ComPage
{
    public class ExcelBase
    {
        //private Microsoft.Office.Interop.Excel.Application app = null;
        //private Microsoft.Office.Interop.Excel.Workbook workbook = null;
        //private Microsoft.Office.Interop.Excel.Worksheet worksheet = null;
        //private Microsoft.Office.Interop.Excel.Range workSheet_range = null;

        public ExcelBase()
        {
            createDoc();
        }

        public void createDoc()
        {
            try
            {
                //app = new Microsoft.Office.Interop.Excel.Application();
                //app.Visible = true;
                //workbook = app.Workbooks.Add(1);
                //worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets[1];
            }
            catch (Exception e)
            {
                Console.Write("Error");
            }
            finally
            {
            }
        }

        //public void InsertData(ExcelBE be,string sType)
        //{
        //    worksheet.Cells[be.Row, be.Col] = be.Text;
        //    workSheet_range = worksheet.get_Range(be.StartCell, be.EndCell);
        //    workSheet_range.MergeCells = be.IsMerge;
        //    workSheet_range.Interior.Color = GetColorValue(be.InteriorColor);
            
        //    workSheet_range.ColumnWidth = be.Size;
        //    workSheet_range.Font.Color = GetColorValue(be.FontColor);
        //    workSheet_range.NumberFormat = be.Formart;
        //    workSheet_range.HorizontalAlignment = 3;
        //    workSheet_range.VerticalAlignment = 3;
        //    if (sType.Trim().Equals("1"))
        //    {
        //        workSheet_range.Font.Size = 17;
        //        workSheet_range.Font.Bold = true;
        //    }
        //    else if (sType.Trim().Equals("2"))
        //    {
        //        workSheet_range.Borders.Color = GetColorValue(be.BorderColor);
        //    }
        //}

        private int GetColorValue(string interiorColor)
        {
            switch (interiorColor)
            {
                case "YELLOW":
                    return System.Drawing.Color.Yellow.ToArgb();
                case "Black":
                    return System.Drawing.Color.Black.ToArgb();
                case "Green":
                    return System.Drawing.Color.Green.ToArgb();
                case "Red":
                    return System.Drawing.Color.Red.ToArgb();

                default:
                    return System.Drawing.Color.White.ToArgb();
            }
        }
    }
}